<style scoped>
  .rj-topbar {
    height: 50px; line-height: 50px; background: #f7f7f7; text-align: center; font-size: 16px; border-bottom: 1px solid #bdbbbc; position: relative
  }
  .list {
    background: #eee;
  }
  .weui-form-preview {
    background-color: #fff;
    margin: 5px;
    border-radius: 5px;
  }
  .weui-form-preview__hd label, .weui-form-preview__hd em {
    font-size: .9em !important;
  }
  .weui_navbar_item {
    font-size: 14px;
  }
  .weui_navbar_item.weui_bar_item_on {
    color: #3cc51f;
  }
  .weui-loadmore_line .weui-loadmore__tips {
    background-color: #eee;
  }
  .list {
    overflow: auto;
  }
  .rj-cell {
    display: inline-block;
    font-size: 0;
    padding: 5px 15px;
  }
  .rj-cell.max span{
    font-size: 16px;
    padding-right: 20px;
  }
  .rj-cell.minpad{
    padding-right: 10px !important;
  }
  .rj-cell label {
    color: #333;
    font-size: 14px;
  }
  .rj-cell span {
    padding-left: 5px;
    font-size: 14px;
    color: #333;
  }
  .rj-cell.note{
    width: 100%;
  }
  .rj-cell.note label{
    float: left;
  }
  .rj-cell.note span{
    width: 80%;
    display: inline-block;
  }
  .weui-cells {
    margin-top: 0;
  }
  .rj-wrap {
    background: #eee;
    overflow:auto;overflow-x: hidden
  }
  .rj-cont {
    background: #fff;
  }
  .weui-panel {
    background: #eee;
  }
  .rj-cont-tit {
    margin: 0;
    border-radius: 0;
  }
  .weui-panel {
    margin-top: 0;
    text-align: left;
  }
  .hd .weui-grid.js_grid {
    font-weight: 600;
  }
  .weui-grid.js_grid {
    width: 20%;
    padding: 10px 1px;
  }
  .weui-grid.fir {
    width: 30%;
  }
  .weui-grid.sec {
    width: 20%;
  }
  .weui-grid.thr {
    width: 20%;
  }
  .weui-grid.fou {
    width: 15%;
  }
  .weui-grid.fiv {
    width: 15%;
  }
  .weui-grid__label {
    text-overflow: initial;
  }
</style>
<template>
  <div>
    <div class="rj-wrap">
      质检详情
      <a href="javascript:;" @click="toPrevUrl(getUrlParam())" style="position: absolute; left: 10px; top: 8px">
        <img src="@/assets/back.png" style="width: 20px" />
      </a>
    </div>
    <div class="weui-panel weui-panel_access">
      <div class="weui-panel__bd">
        <div class="weui-form-preview billitem rj-cont-tit">
          <div class="rj-cell max">
            <label>货运单编号：</label>
            <span>{{baseInfo.code}}</span>
          </div>
          <div class="rj-cell max">
            <label>车牌号：</label>
            <span>{{baseInfo.carcode}}</span>
          </div>
          <div class="rj-cell max">
            <label>货品：</label>
            <span>{{baseInfo.variety + ' ' + baseInfo.specification}}</span>
          </div>
          <div class="rj-cell max" v-if="contract.regionName != ''">
            <label>区域：</label>
            <span style="color: red;">{{contract.regionName}}</span>
          </div>
          <div class="rj-cell max" v-if="contract.seriesName != ''">
            <label>系列：</label>
            <span style="color: red;">{{contract.seriesName}}</span>
          </div>
          <div class="rj-cell max">
            <label>种植户：</label>
            <span>{{baseInfo.plantor}}</span>
          </div>
          <div class="rj-cell max">
            <label>装车时间：</label>
            <span>{{baseInfo.createtime}}</span>
          </div>
          <div class="rj-cell max">
            <label>状态：</label>
            <span>{{baseInfo.statusname}}</span>
          </div>
          <div class="rj-cell max">
            <label>负责人：</label>
            <span>{{baseInfo.operator}}</span>
          </div>
        </div>
      </div>
      <div class="weui-panel__hd">
        质检明细
        <span style="color: #00913a;float: right;" @click="toQainfo">概况 >></span>
      </div>
      <div class="weui-panel__bd" style="background: #fff;">
        <div class="weui-grids">
          <div class="row hd">
            <a href="#" class="weui-grid js_grid fir">
              <p class="weui-grid__label">
                质检项
              </p>
            </a>
            <a href="#" class="weui-grid js_grid sec">
              <p class="weui-grid__label">
                结果(%)
              </p>
            </a>
            <a href="#" class="weui-grid js_grid thr">
              <p class="weui-grid__label">
                是否合格
              </p>
            </a>
            <a href="#" class="weui-grid js_grid fou">
              <p class="weui-grid__label">
                奖励
              </p>
            </a>
            <a href="#" class="weui-grid js_grid fiv">
              <p class="weui-grid__label">
                扣罚
              </p>
            </a>
          </div>
          <template v-for="item in qaresult">
            <div class="row">
              <a href="#" class="weui-grid js_grid fir">
                <p class="weui-grid__label">
                  {{item.qaitemname}}
                </p>
              </a>
              <a href="#" class="weui-grid js_grid sec">
                <p class="weui-grid__label">
                  {{item.type == 6 ? item.qaitemresult == 1 ? '有' : '无' : item.qaitemresult}}
                </p>
              </a>
              <a href="#" class="weui-grid js_grid thr">
                <p class="weui-grid__label">
                  {{item.qualified == 1 ? '是' : '否'}}
                </p>
              </a>
              <a href="#" class="weui-grid js_grid fou">
                <p class="weui-grid__label">
                  {{baseInfo.acceptStatus != 1 && item.type != 4 ? '-' : item.awardamount}}
                </p>
              </a>
              <a href="#" class="weui-grid js_grid fiv">
                <p class="weui-grid__label">
                  {{baseInfo.acceptStatus != 1 && item.type != 4 ? '-' : item.deductamount}}
                </p>
              </a>
            </div>
          </template>
        </div>
        <div class="weui-form-preview billitem rj-cont-tit">
          <div class="rj-cell" style="display: block;">
            <label>质检结果：</label>
            <span>{{baseInfo.acceptStatus == 1 ? '合格' : '不合格'}}</span>
          </div>
          <div class="rj-cell" style="display: block;">
            <label>结算单价：</label>
            <span v-if="baseInfo.acceptStatus == 1">({{price}}+{{awardamount}}-{{deductamount}}) * (1-{{qaform.soilchkrate}}%)={{baseInfo.actualSettl}}</span>
            <span v-if="baseInfo.acceptStatus == 2">({{price}}+{{awardamount}}-{{deductamount}}) * (1-{{qaform.soilchkrate}}%)={{baseInfo.actualSettl}}</span>
          </div>
<!--          <div class="rj-cell max" style="width: 100%;text-align: right;">-->
<!--            <span v-if="baseInfo.acceptStatus == 1">({{price}} + {{awardamount}} - {{deductamount}}) * (1- {{qaform.soilchkrate}}%) = {{baseInfo.actualSettl}}</span>-->
<!--            <span v-if="baseInfo.acceptStatus == 2">({{price}} + {{awardamount}} - {{deductamount}}) * (1- {{qaform.soilchkrate}}%) = {{baseInfo.actualSettl}}</span>-->
<!--          </div>-->
        </div>

      </div>
    </div>
  </div>
</template>

<script>
  import SalesOperationLogs2 from '../../common/SalesOperationLogs2'

  export default {
    name: 'ViewSellform',
    data () {
      return {
        id: '',
        qaform: '',
        baseInfo: '',
        qaresult: [],
        price: '',
        awardamount: '',
        deductamount: '',
        contract: '',
        qamaintype: ''
      }
    },
    components: {
      SalesOperationLogs2
    },
    mounted () {
      this.id = this.$route.query.id;
      this.getBaseinfo(this.id);
    },
    activated() {
    },
    methods: {
      getUrlParam: function(name) {
        return window.location.href.split("fromurl=")[1];
      },
      toQainfo: function() {
        const path = encodeURIComponent(location.href);
        location.href = `/harvest/Qarecord!detail.action?s=${this.baseInfo.guid}&door=list&fromurl=${path}`;
      },
      getBaseinfo: function (id) {
        this.axios({
          method: 'post',
          url: '/harvest/Freightorder!getAcceptInfo.action',
          params: {guid: id}
        }).then(response => {
          if (response.data.msg == 'success') {
            this.baseInfo = response.data.order || {};
            this.qaform = response.data.qaform || {};
            this.qamaintype = response.data.qamaintype;
            this.qaresult = response.data.qaresult.filter(item => {
              if (this.qamaintype != 2) {
                if (item.type == 4) {
                  if (this.baseInfo.acceptStatus != 1) {
                    return true;
                  }
                  return false;
                }
              }
              return true;
            }) || [];
            this.price = response.data.price || '';
            this.awardamount = response.data.awardamount;
            this.deductamount = response.data.deductamount;
            this.contract = response.data.contract;
          } else if (response != undefined && response.data != undefined && response.data.msg == 'sessionTimeOut') {
            //不不设置提示
          } else {
            this.toastText('获取质检数据失败');
          }
        });
      },
      openLogs: function() {
        if (this.sellform.flag == 3) {
          this.$router.push({name: 'SalesOperationLogs2', query: {orderid: this.id, srguid: this.sellform.storermguid, departid: this.sellform.depguid, sellformpid: this.sellform.parentguid, sellformpcode: this.sellform.parentcode}});
        } else {
          this.$router.push({name: 'SalesOperationLogs2', query: {orderid: this.id, srguid: this.sellform.storermguid, departid: this.sellform.depguid}});
        }
      },
    }
  }
</script>
